import {h, compile} from 'vue'

// 定义表格列
export const COLUMNS = ([
  {
    title: '菜单名称',
    dataIndex: 'name',
    ellipsis: true,
    tooltip: {position: 'left'},
  },
  {
    title: '类型',
    dataIndex: 'type',
    ellipsis: true,
    tooltip: {position: 'left'},
    width: 110,
    render(data) {
      if (data.record.type == 1) {
        return h(compile(`<a-tag color="green">目录</a-tag>`))
      } else if (data.record.type == 2) {
        return h(compile(`<a-tag color="blue">菜单</a-tag>`))
      } else if (data.record.type == 3) {
        return h(compile(`<a-tag color="magenta">操作权限</a-tag>`))
      }
    }
  },
  {
    title: '图标',
    dataIndex: 'icon',
    ellipsis: true,
    tooltip: {position: 'left'},
    width: 80,
    render(data) {
      if (data.record.icon && data.record.icon.length > 1) {
        return h(compile(`<${data?.record?.icon} size="20px"/>`))
      }
    }
  },
  {
    title: '路由路径',
    dataIndex: 'path',
    ellipsis: true,
    tooltip: {position: 'left'},
  },
  {
    title: '组件路径',
    dataIndex: 'component',
    ellipsis: true,
    tooltip: {position: 'left'},
  },
  {
    title: '权限编码',
    dataIndex: 'perms',
    ellipsis: true,
    tooltip: {position: 'left'},
  },
  {
    title: '状态',
    dataIndex: 'status',
    ellipsis: true,
    tooltip: {position: 'left'},
    width: 100,
    slotName: 'status',
  },
  {
    title: '排序',
    dataIndex: 'sort',
    ellipsis: true,
    tooltip: {position: 'left'},
    width: 70,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    ellipsis: true,
    tooltip: { position: 'left' },
  },
  {
    title: '操作',
    ellipsis: true,
    fixed: 'right',
    align: 'left',
    slotName: 'operations',
  }
]);